const { PermissionDeniedError } = require('../errors/application-error.js')

module.exports = function () {
  return async (ctx, next) => {
    if (!ctx.state.isSuper) {
      throw new PermissionDeniedError()
    }
    await next()
  }
}
